package cn.schoolwow.util.test.module.query.instanceList.flow.query;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.util.domain.query.instanceList.QueryInstanceList;
import cn.schoolwow.util.test.module.common.domain.User;
import org.junit.Assert;

import java.util.List;

public class InstanceQueryListFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        List<User> userList = (List<User>) flowContext.checkData("userList");
        String password = (String) flowContext.checkData("password");

        List<User> queryUserList = QueryInstanceList.newQuery(userList)
                .addQuery("password", password)
                .addQuery("address", null)
                .execute()
                .getList();
        Assert.assertEquals(userList.size(), queryUserList.size());
    }

    @Override
    public String name() {
        return "用户实例列表查询";
    }
}
